package gameManager;
import java.io.File;
import java.util.List;
import javax.swing.JFileChooser;
/**
 * @author Xi Du
 * Create the player record manager.
 */
public abstract class PlayRecordManager{
    /**
     * @param currentPlayer current player
     */
    private Player currentPlayer;
    /**
     * @param playerFile player file
     */
    private List<Player> playerFile;
/**
 * constructor for the record manager
 */
        public PlayRecordManager(){
           playerFile = loadPlayer(chooseFile());
           playerLogin();
           setcurrentPlayer(playerLogin());
        }
/**
 * 
 * @return return player's file
 */
        public File chooseFile () {
            File returnFile = null;
            JFileChooser chooser = new JFileChooser(System.getProperties().getProperty("user.dir"));
            int response = chooser.showOpenDialog(null);
            if (response == JFileChooser.APPROVE_OPTION) {
                returnFile = chooser.getSelectedFile();
            }
            return returnFile;
        }
/**
 * 
 * @param playerFile player's file
 * @return player list
 */
public abstract List<Player> loadPlayer(File playerFile);
/**
         * update record
         */
public abstract void updateRecord();
/**
         * 
         * @return player file
         */
public List<Player> getPlayer(){
return playerFile;
}
/**
 * 
 * @return return player
 */
        public abstract Player playerLogin();
/**
 * 
 * @return currentPlayer return current player
 */
        public Player getCurrentPlayer(){
        return currentPlayer;
        }
/**
 * 
 * @param player player
 */
        public void setcurrentPlayer(Player player){
        currentPlayer=player;
        }
}